﻿using IdentityServer4.Models;
using IdentityServer4.Services;

namespace JWTAPI.AuthorInfo;

/// <summary>
/// IdentityServer提供了接口访问用户信息，但是默认返回的数据只有sub，就是上面设置的subject: context.UserName，
/// 要返回更多的信息，需要实现IProfileService接口：
/// </summary>
public class ResourceOwnerPasswordProfileService : IProfileService
{
    public Task GetProfileDataAsync(ProfileDataRequestContext context)
    {
        //depending on the scope accessing the user data.
        var claims = context?.Subject?.Claims.ToList();
        //set issued claims to return
        context.IssuedClaims = claims;
        return Task.CompletedTask;
    }

    public Task IsActiveAsync(IsActiveContext context)
    {
        context.IsActive = true;
        return Task.CompletedTask;
    }
}
